from django.db import models
from django.contrib.auth.models import AbstractUser





class Identity(models.Model):
    level = models.CharField(max_length=32)
    name = models.CharField(max_length=150, verbose_name='身份等级名')

    def __str__(self):
        return self.name

class User(models.Model):
    username = models.CharField(max_length=150, unique=True)
    password = models.CharField(max_length=150)
    level = models.CharField(max_length=32)
    phone = models.CharField(max_length=11)
    email = models.CharField(max_length=100)
    def __str__(self):
        return self.username

class User_Node(models.Model):
    user = models.ForeignKey(User,on_delete=models.CASCADE)
    node = models.ForeignKey(Identity,on_delete=models.CASCADE)

    class Meta:
        db_table = 'user_node'

class DingTalkUser(models.Model):
    username = models.CharField(max_length=30)
    unionid = models.CharField(max_length=60)
    dingId = models.CharField(max_length=60)
    openid = models.CharField(max_length=60)

    class Meta:
        db_table = 'dingtalk'

class Cate(models.Model):

    name = models.CharField(max_length=50, verbose_name='工单分类名')
    pid = models.IntegerField(verbose_name='父级id')

    class Meta:

        db_table = 'cate'

